package com.zegome.game.oanquan.scene.play;

import java.util.ArrayList;

import com.badlogic.gdx.math.Vector2;
import com.zegome.game.entity.sprite.Sprite;

/**
 * (C) 2013 ZeroTeam
 * @author QuanLT
 */

public class PlayerPond {
	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Fields
	// ===========================================================
	private int mQuantity;
	private int mCourting;
	private int mTimeSurPlus;
	private final ArrayList<Sprite> mStoneList;
	
	private final Vector2 mPosition;
	
	// ===========================================================
	// Constructor
	// ===========================================================
	public PlayerPond(final float x, final float y, final int flag) {
		mQuantity = 0;
		mCourting = 0;
		mTimeSurPlus = 0;
		mPosition = new Vector2(x, y);
		mStoneList = new ArrayList<Sprite>();
	}
	
	// ===========================================================
	// Getter & Setter
	// ===========================================================
	public int getQuantity() {
		return mQuantity;
	}
	
	public Vector2 getPosition() {
		return mPosition;
	}
	
	public int getScore(final int level) {
		int sum = 0;
		
		sum += (mQuantity + mCourting * 10) * level + (int)Math.min(mTimeSurPlus * 0.1f, 10);
		
		return sum;
	}
	
	// ===========================================================
	// Methods for/from SuperClass/Interfaces
	// ===========================================================

	// ===========================================================
	// Methods
	// ===========================================================
	public void attachStone(final Sprite stone) {
		if (stone == null) {
			throw new IllegalArgumentException("stone sprite must be different frome null");
		}
		mStoneList.add(stone);
		mQuantity++;
	}
	
	public void detachStone(final Sprite stone) {
		if (stone == null) {
			throw new IllegalArgumentException("stone sprite must be different frome null");
		}
		
		if (!mStoneList.contains(stone)) {
			return;
		}
		mStoneList.remove(stone);
		mQuantity--;
	}
	
	public void addTimeSurPlus(final int time) {
		mTimeSurPlus += time;
	}
	
	public void eatCourting() {
		mCourting++;
	}
	
	public void clear() {
		mStoneList.clear();
		mQuantity = 0;
		mCourting = 0;
		mTimeSurPlus = 0;
	}
	
	// ===========================================================
	// Inner and Anonymous Classes
	// ===========================================================
}
